home *** CD-ROM | disk | FTP | other *** search
- Path: holly.ACNS.ColoState.EDU!not-for-mail
- From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
- Newsgroups: comp.lang.c++
- Subject: Re: No struct in C++!!?
- Date: 27 Feb 1996 21:07:09 -0700
- Organization: Colorado State University, Fort Collins, CO 80523
- Message-ID: <4h0kdd$lb2@holly.ACNS.ColoState.EDU>
- References: <1996Feb14.151620.5532@queens-belfast.ac.uk> <00001a81+0000a7ee@msn.com>
- NNTP-Posting-Host: holly.acns.colostate.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Bing Xiao (bxiao@msn.com) wrote:
- : a beginners question: I found in different C++ books examples of C++ programms
- : which contain type declarations and definitions in the main() programm - for
- : example a struct - as in C.
- : My question is, whether this is a contradiction
- : to the paradigm of C++. Shouldn't be everything in a C++ programm
- : either classes, objects or the interaction between objects?
- : So is it bad C++ style, to use functions or data outside from
- : classes (objects)?
-
- We've had this discussion in my data structures class. It isn't always appropriate
- to encapsulate data when it isn't necessary. In C++, the struct is little more
- than a class with default public access. You can still have member functions
- and data, there is just no access control. I've found that when dealing with
- simple records, it is considerably easier (and more efficient) to use structs
- than to use classes where they would be overkill.
-
-
- // ------------ BEGIN SIGNATURE ---------------
- #include <iostream.h>
- void main()
- {
- cout<<"\aName:\tCorby S. Hudnall\n";
- cout<<"School:\tColorado State University\n";
- cout<<"EMail\tcorbyh@holly.colostate.edu\n";
- cout<<"URL\thttp://holly.colostate.edu/~corbyh/\n";
- }
- // ------------- END SIGNATURE ----------------
-